﻿using System;
using System.Windows.Forms;

namespace Useful
{
    public partial class OptionalDateTimePicker : UserControl
    {
        public event EventHandler ValueChanged;

        public OptionalDateTimePicker()
        {
            InitializeComponent();
        }

        public string Header
        {
            get
            {
                return gbContainer.Text;
            }
            set
            {
                gbContainer.Text = value;
            }
        }

        public GroupBox GroupBoxControl
        {
            get
            {
                return gbContainer;
            }
        }

        public DateTime? Value
        {
            get
            {
                return odtptDateTime.Value;
            }
            set
            {
                odtptDateTime.Value = value;
            }
        }

        public bool PresetVisibility
        {
            get
            {
                return odtptDateTime.PresetVisibility;
            }
            set
            {
                odtptDateTime.PresetVisibility = value;
            }
        }

        public ContextMenuStrip ContextMenuStripControl
        {
            get
            {
                return odtptDateTime.ContextMenuStripControl;
            }
        }

        public DateTime? Date
        {
            get
            {
                return odtptDateTime.Date;
            }
        }

        public DateTimePicker DateTimePickerControl
        {
            get
            {
                return odtptDateTime.DateTimePickerControl;
            }
        }

        public DateTimePickerFormat Format
        {
            get
            {
                return odtptDateTime.Format;
            }
            set
            {
                odtptDateTime.Format = value;
            }
        }

        public string CustomFormat
        {
            get
            {
                return odtptDateTime.CustomFormat;
            }
            set
            {
                odtptDateTime.CustomFormat = value;
            }
        }

        private void odtptDateTime_ValueChanged(object sender, EventArgs e)
        {
            if (ValueChanged != null)
                ValueChanged(this, e);
        }

        public bool ShowCheckBox
        {
            get
            {
                return odtptDateTime.DateTimePickerControl.ShowCheckBox;
            }
            set
            {
                odtptDateTime.DateTimePickerControl.ShowCheckBox = value;
            }
        }
    }
}
